package com.mallcloud.mall.mall.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mallcloud.mall.common.core.util.R;
import com.mallcloud.mall.mall.api.entity.XglQRCodePaymentModel;
import com.mallcloud.mall.mall.api.entity.vo.XglQRCodePaymentVO;
import com.mallcloud.mall.mall.service.XglQRCodePaymentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "mall-星光里二维码支付牌信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/mall/xglQrcodePayment")
public class XglQRCodePaymentController {
    private final XglQRCodePaymentService qrCodePaymentService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    @PreAuthorize("@pms.hasPermission('mall_xglqrcodepayment_view')")
    public R<IPage<XglQRCodePaymentVO>> page(Page<XglQRCodePaymentVO> page, XglQRCodePaymentModel dto) {
		return R.ok(qrCodePaymentService.pageQRCodePayment(page, dto));
    }

	@ApiOperation("列表查询")
	@GetMapping("/list")
	@PreAuthorize("@pms.hasPermission('mall_xglqrcodepayment_view')")
	public R<List<XglQRCodePaymentVO>> list(XglQRCodePaymentModel dto) {
		return R.ok(qrCodePaymentService.listQRCodePayment(dto));
	}

	@ApiOperation("获取立牌信息详细信息")
	@GetMapping("/getInfo")
	@PreAuthorize("@pms.hasPermission('mall_xglqrcodepayment_view')")
	public R<XglQRCodePaymentModel> getInfo(XglQRCodePaymentVO dto) {
		return R.ok(qrCodePaymentService.getById(dto.getMerchantCode()));
	}

}
